<template>
  <el-input-number class="input-block"
    v-bind="$props"
    autofocus
    :key=""
    v-model="editorVal"
    @change="handleChange"/>
</template>
<script>
  import * as ui from 'l-element'
  export default {
    props: {
      ...ui.default.Input.props, // 继承Input的所有属性
      data: Object,
      type: String,
      debounce: Number
    },
    data () {
      let editorVal = this.data.row[this.type]
      return {
        editorVal: editorVal,
        key: Math.random()
      }
    },
    methods: {
      handleChange (newVal) {
        if (this.type === 'price') {
          newVal = parseInt((newVal * 10000) / 100) / 100
          this.$el.value = newVal
          this.key = Math.random()
        }
        this.$emit('change', newVal, this.type, this.data)
          .$emit('blur', newVal, this.type, this.data)
      }
    }
  }
</script>
